# -*- coding:utf-8 -*-

import os

basePath = "./conifg/"

def readConfigJson(fileName):
    if not os.path.exists(basePath) :
        os.makedirs(basePath)
    if not os.path.exists(basePath+fileName) :
        with open(basePath+fileName,"w") as f:
            pass

    fjson = open(basePath+fileName,"r")
    read = fjson.read()
    fjson.close()
    if(read == ''):
        read = '{}'

    return read

def writeConfigJson(fileName , jsonstr):
    if not os.path.exists(basePath) :
        os.makedirs(basePath)
    fjson = open(basePath+fileName,"w")
    fjson.write(jsonstr)
    fjson.close()
    return True

if __name__ == '__main__':
    # path = "C:\\Users\\alvin\\OneDrive\\桌面\\摄影作品"
    # for root, dirs, files in os.walk(path):
    #     print(root)
    #
    #     print(files)
    #     for na in files:
    #         print(root+"\\"+na)
    #
    #     print("\n")
    # writeConfigJson("music.json",'{"aa":"bb"}')
    print(readConfigJson("music.json"))
    pass


